package com.test.daily.leetcode.y2022.m05.day0519.v05;

import java.util.Arrays;

/**
 * @descriptions:
 * @author: Tom
 * @date: 2022/5/19 下午 09:33
 * @version: 1.0
 */
public class Solution {
    public static void main(String[] args) {

    }
    public int minMoves21(int[] nums) {
        Arrays.sort(nums);
        int N = nums.length;
        int mid = nums[N/2];
        int ans = 0;
        for (int i = 0; i < N; i++) {
            ans += Math.abs(nums[i] - mid);
        }
        return ans;
    }
}
